package com.definity.toolkit.ui.widget;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JTextField;

import com.definity.toolkit.ui.Body;

public class TextField extends JTextField implements Widget<TextField> {

	private static final long serialVersionUID = -3966169581499341190L;

	public TextField() {
		super();
	}

	public TextField(String text) {
		super(text);
	}

	@Override
	public String id() {
		return getName();
	}

	@Override
	public TextField id(String id) {
		setName(id);
		return this;
	}

	@Override
	public TextField properties(Body<TextField> body) {
		body.content(this);
		return this;
	}

	public TextField size(int width, int height) {
		setPreferredSize(new Dimension(width, height));
		return this;
	}

	public String text() {
		return getText();
	}

	public TextField text(String text) {
		setText(text);
		return this;
	}

	@Override
	public Color background() {
		return getBackground();
	}

	@Override
	public TextField background(Color background) {
		setBackground(background);
		return this;
	}

	@Override
	public Color foreground() {
		return getForeground();
	}

	@Override
	public TextField foreground(Color foreground) {
		setForeground(foreground);
		return this;
	}

	@Override
	public Font font() {
		return getFont();
	}

	@Override
	public TextField font(Font font) {
		setFont(font);
		return this;
	}
	
}
